/**
 * Class describing a group of students
 * 
 * @author Timur Suleimanov
 * @param groupName
 *            Stands for group name
 */
class Group {
	private Student[] students;
	private String groupName;

	public Group(String groupName) {
		this.groupName = groupName;
	}

	public String getGroupName() {
		return groupName;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}

	public void setStudents(Student[] students) {
		this.students = students;
	}

	public Student[] getStudents() {
		return this.students;
	}

	/**
	 * Adding new students to the group
	 * 
	 * @param group
	 *            A group to which student should be added
	 * @param newStudent
	 *            Student to add
	 * @return Returning an array of students with new student
	 */
	public Student[] addStudent(Group group, Student newStudent) {
		Student[] students = group.getStudents();
		Student[] temp = new Student[students.length + 1];
		for (int i = 0; i < students.length; i++) {
			temp[i] = students[i];
		}
		temp[temp.length - 1] = newStudent;
		return temp;
	}

	/**
	 * Deleting student from a group
	 * 
	 * @param group
	 *            A group where student is studying
	 * @param studentToDelete
	 *            Student to delete
	 * @return Returning an array of students without deleted students
	 */
	public Student[] deleteStudent(Group group, Student studentToDelete) {
		Student[] students = group.getStudents();
		Student[] temp = new Student[students.length - 1];
		int index = 0;
		for (int i = 0; i < students.length; i++) {
			if (!students[i].equals(studentToDelete)) {
				System.arraycopy(students, i, temp, index++, 1);
			}
		}
		return temp;
	}

}